﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="SetAccount.aspx.cs" Inherits="User_SetAccount" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>账号绑定</title>
    <script src="../Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
    <script type="text/javascript" src="../ePioneer/javascript/jq_fn.js"></script>
    <link href="css/zhuce.css" rel="stylesheet" type="text/css" />
    <link href="../ePioneer/css/main.css" rel="stylesheet" type="text/css" />
    <link href="../ePioneer/css/m_dp02.css" rel="stylesheet" type="text/css" />
</head>
<body style="border-style: none" scroll="no" topmargin="0" leftmargin="0">
    <div class="dp_m">
        <div class="dp_top">
        </div>
        <div class="cnt">
            <script src="js/header.js" type="text/javascript"></script>
            <div class="posbar dpbar_kefu">
                <div class="topmenu">
                    <div class="tmitem tmi_2 tmi_on2" style="cursor: pointer;">
                    </div>
                </div>
            </div>
            <div style="border-color: #d1d3d5; border-style: solid; border-bottom: 1px; height: 410px;
                border-left: 1px; border-right: 1px; width: 771px; margin-left: 10px; margin-bottom: 10px;
                margin-right: 10px;">
                <div class="cpzx_zc_main" style="margin: auto;">
                    <div class="cpzx_zc_mainm">
                        <div class="cpzx_zc_up" style="display: none;">
                            <div class="cpzx_zc_yonghu">
                                <img src="image/yh_13.jpg" width="22" height="21" alt="" /></div>
                            <div class="cpzx_zc_huanyin">
                                欢迎您，<span id="userLoginName"><%=userLoginName %></span></div>
                            <div class="cpzx_zc_tuichu" style="display: none;">
                                退出</div>
                            <div class="clear">
                            </div>
                        </div>
                        <div class="cpzx_zc_step">
                            <div class="cpzx_zc_step1">
                                <span class="color_gray color_yellow">多登录账号设置</span></div>
                            <div class="cpzx_zc_step2">
                                <span class="color_gray">>>>登录信息设置</span></div>
                            <div class="cpzx_zc_step1">
                                <span class="color_gray">>>> 设置成功</span></div>
                            <div class="clear">
                            </div>
                        </div>
                        <div class="cpzx_zc_tiao">
                        </div>
                        <div class="cpzx_zc_duo">
                            <div class="cpzx_zc_duox">
                                <div class="cpzx_zc_duox1">
                                    <div class="cpzx_zc_fangshi">
                                        设置益盟号登录方式</div>
                                    <div id="strEM">
                                        <%=strEM %></div>
                                    <div class="clear">
                                    </div>
                                </div>
                            </div>
                            <div class="cpzx_zc_duox">
                                <div class="cpzx_zc_duox1">
                                    <div class="cpzx_zc_fangshi">
                                        设置手机号码登录方式</div>
                                    <div id="strMobile">
                                        <%=strMobile %></div>
                                    <div class="clear">
                                    </div>
                                </div>
                            </div>
                            <div class="cpzx_zc_duox">
                                <div class="cpzx_zc_duox1">
                                    <div class="cpzx_zc_fangshi">
                                        设置邮箱登录方式</div>
                                    <div id="strEmail">
                                        <%=strEmail %></div>
                                    <div class="clear">
                                    </div>
                                </div>
                            </div>
                            <div class="cpzx_zc_duox1">
                                <div class="cpzx_zc_fangshi">
                                    设置昵称登录方式</div>
                                <div id="strNickname">
                                    <%=strNickname%></div>
                                <div class="clear">
                                </div>
                            </div>
                        </div>
                        <div class="cpzx_zc_dlall" style="display: none;">
                            <div class="cpzx_zc_dlsj">
                                <div class="cpzx_zc_sjz">
                                    益盟号</div>
                                <div class="cpzx_zc_dlsr">
                                    <input id="txt_EM" name="dlsr" type="text" maxlength="50" style="margin-left: 8px;
                                        line-height: 22px; width: 168px; height: 20px; float: left; margin-top: 1px;" /></div>
                            </div>
                            <div class="clear">
                            </div>
                            <div class="cpzx_zc_jiange">
                                <div class="cpzx_zc_gantan">
                                </div>
                                <div class="cpzx_zc_gantanz">
                                    请输入您的益盟号</div>
                                <div class="clear">
                                </div>
                            </div>
                            <div class="cpzx_zc_dlsj">
                                <div class="cpzx_zc_sjz">
                                    密码</div>
                                <div class="cpzx_zc_dlsr">
                                    <input id="txt_EMPW" name="dlsr" type="text" maxlength="20" style="margin-left: 8px;
                                        line-height: 22px; width: 168px; height: 20px; float: left; margin-top: 1px;" /></div>
                                <div class="pl8" style="display: none;">
                                    <img src="image/button1_25.jpg" width="70" height="23" /></div>
                            </div>
                            <div class="clear">
                            </div>
                            <div class="cpzx_zc_jiange" style="display: none;">
                                <div class="cpzx_zc_gantan">
                                </div>
                                <div class="cpzx_zc_gantanz">
                                    如未收到验证码，请再次点击"获取验证码"</div>
                                <div class="clear">
                                </div>
                            </div>
                            <div class="cpzx_zc_qdqx">
                                <div class="cpzx_zc_qdbutton">
                                    <img src="image/button1_32.jpg" width="83" height="34" alt="" style="cursor: pointer;"
                                        onclick="SubmitAccount('strEM',4);" /></div>
                                <div class="cpzx_zc_qdbutton">
                                    <img src="image/button1_34.jpg" width="83" height="34" alt="" style="cursor: pointer;"
                                        onclick="SetAccount();" /></div>
                            </div>
                        </div>
                        <div class="cpzx_zc_dlall" style="display: none;">
                            <div class="cpzx_zc_dlsj">
                                <div class="cpzx_zc_sjz">
                                    手机号</div>
                                <div class="cpzx_zc_dlsr">
                                    <input id="txt_Mobile" name="dlsr" maxlength="11" type="text" style="margin-left: 8px;
                                        line-height: 22px; width: 168px; height: 20px; float: left; margin-top: 1px;" /></div>
                            </div>
                            <div class="clear">
                            </div>
                            <div class="cpzx_zc_jiange">
                                <div class="cpzx_zc_gantan">
                                </div>
                                <div class="cpzx_zc_gantanz">
                                    请输入您的手机号码</div>
                                <div class="clear">
                                </div>
                            </div>
                            <div class="cpzx_zc_dlsj">
                                <div class="cpzx_zc_sjz">
                                    验证码</div>
                                <div class="cpzx_zc_dlsr">
                                    <input id="txt_MobileCode" name="dlsr" maxlength="20" type="text" style="margin-left: 8px;
                                        line-height: 22px; width: 168px; height: 20px; float: left; margin-top: 1px;" /></div>
                                <div class="pl8">
                                    <input type="button" onclick="return GetVerifyCodeUserMob();" style="cursor: pointer;
                                        width: 73px; height: 24px; background: url(image/GetPwd.PNG) 0px 0px no-repeat;" /></div>
                            </div>
                            <div class="clear">
                            </div>
                            <div class="cpzx_zc_jiange">
                                <div class="cpzx_zc_gantan">
                                </div>
                                <div class="cpzx_zc_gantanz">
                                    如未收到验证码，请再次点击"获取验证码"</div>
                                <div class="clear">
                                </div>
                            </div>
                            <div class="cpzx_zc_qdqx">
                                <div class="cpzx_zc_qdbutton">
                                    <img src="image/button1_32.jpg" width="83" height="34" alt="" style="cursor: pointer;"
                                        onclick="SubmitAccount('strMobile',3);" /></div>
                                <div class="cpzx_zc_qdbutton">
                                    <img src="image/button1_34.jpg" width="83" height="34" alt="" style="cursor: pointer;"
                                        onclick="SetAccount();" /></div>
                            </div>
                        </div>
                        <div class="cpzx_zc_dlall" style="display: none;">
                            <div class="cpzx_zc_dlsj">
                                <div class="cpzx_zc_sjz">
                                    邮箱</div>
                                <div class="cpzx_zc_dlsr">
                                    <input id="txt_Email" name="dlsr" type="text" maxlength="50" style="margin-left: 8px;
                                        line-height: 22px; width: 168px; height: 20px; float: left; margin-top: 1px;" /></div>
                            </div>
                            <div class="clear">
                            </div>
                            <div class="cpzx_zc_jiange">
                                <div class="cpzx_zc_gantan">
                                </div>
                                <div class="cpzx_zc_gantanz">
                                    请输入您的邮箱地址</div>
                                <div class="clear">
                                </div>
                            </div>
                            <div class="cpzx_zc_dlsj">
                                <div class="cpzx_zc_sjz">
                                    验证码</div>
                                <div class="cpzx_zc_dlsr">
                                    <input id="txt_EmailCode" name="dlsr" type="text" style="margin-left: 8px; line-height: 22px;
                                        width: 168px; height: 20px; float: left; margin-top: 1px;" /></div>
                                <div class="pl8">
                                    <input type="button" onclick="return GetVerifyCodeUserMail();" style="cursor: pointer;
                                        width: 73px; height: 24px; background: url(image/GetPwd.PNG) 0px 0px no-repeat;" /></div>
                            </div>
                            <div class="clear">
                            </div>
                            <div class="cpzx_zc_jiange">
                                <div class="cpzx_zc_gantan">
                                </div>
                                <div class="cpzx_zc_gantanz">
                                    如未收到验证码，请再次点击"获取验证码"</div>
                                <div class="clear">
                                </div>
                            </div>
                            <div class="cpzx_zc_qdqx">
                                <div class="cpzx_zc_qdbutton">
                                    <img src="image/button1_32.jpg" width="83" height="34" alt="" style="cursor: pointer;"
                                        onclick="return SubmitAccount('strEmail',2);" /></div>
                                <div class="cpzx_zc_qdbutton">
                                    <img src="image/button1_34.jpg" width="83" height="34" alt="" style="cursor: pointer;"
                                        onclick="SetAccount();" /></div>
                            </div>
                        </div>
                        <div class="cpzx_zc_dlall" style="display: none;">
                            <div class="cpzx_zc_dlsj">
                                <div class="cpzx_zc_sjz">
                                    昵称</div>
                                <div class="cpzx_zc_dlsr">
                                    <input id="txt_Nickname" maxlength="50" name="dlsr" type="text" style="margin-left: 8px;
                                        line-height: 22px; width: 168px; height: 20px; float: left; margin-top: 1px;" /></div>
                            </div>
                            <div class="clear">
                            </div>
                            <div class="cpzx_zc_jiange">
                                <div class="cpzx_zc_gantan">
                                </div>
                                <div class="cpzx_zc_gantanz">
                                    请输入您的昵称</div>
                                <div class="clear">
                                </div>
                            </div>
                            <div class="cpzx_zc_dlsj">
                                <div class="cpzx_zc_sjz">
                                    密码</div>
                                <div class="cpzx_zc_dlsr">
                                    <input id="txt_NicknamePW" name="dlsr" maxlength="20" type="text" style="margin-left: 8px;
                                        line-height: 22px; width: 168px; height: 20px; float: left; margin-top: 1px;" /></div>
                                <div class="pl8" style="display: none;">
                                    <img src="image/button1_25.jpg" width="70" height="23" /></div>
                            </div>
                            <div class="clear">
                            </div>
                            <div class="cpzx_zc_jiange" style="display: none;">
                                <div class="cpzx_zc_gantan">
                                </div>
                                <div class="cpzx_zc_gantanz">
                                    如未收到验证码，请再次点击"获取验证码"</div>
                                <div class="clear">
                                </div>
                            </div>
                            <div class="cpzx_zc_qdqx">
                                <div class="cpzx_zc_qdbutton">
                                    <img src="image/button1_32.jpg" width="83" height="34" alt="" style="cursor: pointer;"
                                        onclick="return SubmitAccount('strNickname',1);" /></div>
                                <div class="cpzx_zc_qdbutton">
                                    <img src="image/button1_34.jpg" width="83" height="34" alt="" style="cursor: pointer;"
                                        onclick="SetAccount();" /></div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="dp_bottom">
            <img src="../ePioneer/images/dpm_bg4.gif" width="794" height="9" /></div>
    </div>
    <input type="hidden" runat="server" id="hid_LoginName" />
    <script type="text/javascript">

        //获取邮箱验证码
        function GetVerifyCodeUserMail() {
            var email = $.trim($("#txt_Email").val());
            var testEmail = new RegExp("\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*");
            if (!testEmail.test(email)) {
                alert("邮箱地址格式不正确");
                return false;
            }
            $.ajax({
                type: "POST",
                url: "../UpdateUserInfo.ashx",
                dataType: "json",
                data: { action: "GetVerifyCodeUserMail", email: email },
                success: function (result) {
                    if (result[0] == '0') {
                        alert(result[1]);
                    }
                    else if (result[0] == '-2') {
                        alert("该邮箱地址已被注册");
                        return false;
                    }
                    else {
                        alert(result[1]);
                        return false;
                    }
                }
            });
        }

        //获取手机验证码
        function GetMobileVerify() {
            var mobile = $.trim($("#txt_Mobile").val());
            var testMobile = new RegExp("^0{0,1}(13[0-9]|15[0-9]|180|147|182|18[4-9])[0-9]{8}$");
            if (!testMobile.test(mobile)) {
                alert("手机格式不正确");
                return false;
            }
            $.ajax({
                type: "POST",
                url: "../UpdateUserInfo.ashx",
                dataType: "json",
                data: { action: "GetVerifyCodeUserMob", mobile: mobile },
                success: function (result) {
                    if (result[0] == '0') {
                        alert(result[1]);
                    }
                    else {
                        alert(result[1]);
                        return false;
                    }
                }
            });
        }

        //账号设置
        function SetAccount(id) {
            if (id != null) {
                $(".cpzx_zc_dlall").hide();
                $(".cpzx_zc_duo").hide();
                $(".cpzx_zc_dlall").eq(id).show();
                $(".cpzx_zc_step .color_gray").eq(1).addClass("color_yellow");
            }
            else {
                $(".cpzx_zc_step .color_gray").eq(1).removeClass("color_yellow");
                $(".cpzx_zc_dlall").hide();
                $(".cpzx_zc_duo").show();
            }
        }
        //提交账号设置信息
        function SubmitAccount(id, loginType) {
            var loginName = $.trim($("#hid_LoginName").val());
            var userName = $.trim($("#txt_Nickname").val());
            var passWord = $("#txt_NicknamePW").val();
            if (loginType == 2) {
                userName = $.trim($("#txt_Email").val());
                passWord = $("#txt_EmailCode").val();
            }
            if (loginType == 3) {
                userName = $.trim($("#txt_Mobile").val());
                passWord = $("#txt_MobileCode").val();
            }
            if (loginType == 4) {
                userName = $.trim($("#txt_EM").val());
                passWord = $("#txt_EMPW").val();
            }
            if (!CheckLoginName(userName, loginType)) {
                return false;
            }
            $.ajax({
                type: "POST",
                url: "../UpdateUserInfo.ashx",
                dataType: "json",
                data: { action: "SetAccount", loginName: loginName, userName: userName, passWord: passWord, loginType: loginType },
                success: function (result) {
                    if (result[0] == '0') {

                        if (loginType == 2)
                            $("#" + id + "").html("<div class='cpzx_zc_yanz'>已验证</div><div class='cpzx_zc_szbutton'><img src='image/button1_17.jpg' width='73' height='24' style='cursor: pointer;' onclick='SetAccount(2);' /></div>");
                        else if (loginType == 3)
                            $("#" + id + "").html("<div class='cpzx_zc_yanz'>已验证</div><div class='cpzx_zc_szbutton'><img src='image/button1_17.jpg' width='73' height='24' style='cursor: pointer;' onclick='SetAccount(1);' /></div>");
                        else
                            $("#" + id + "").html("<div class='cpzx_zc_yanz'>已验证</div><div class='cpzx_zc_szbutton'><img src='image/button1_17hui.jpg' width='73' height='24' style='cursor: pointer;' /></div>");
                        SetAccount();
                    }
                    else {
                        alert(result[1]);
                        return false;
                    }
                }
            });
        }

        //检查用户名
        function CheckLoginName(loginName, loginType) {
            var testUserId = new RegExp("^0{0,1}(13[0-9]|15[0-9]|180|147|182|18[4-9])[0-9]{8}$");
            if (loginType == 1) {
                if (loginName == "") {
                    alert("昵称不能为空");
                    return false;
                }
                testUserId = new RegExp("^{cps|ems|emoney}*$");
                if (testUserId.test(loginName)) {
                    alert("昵称不能以cps/emoney/ems开头");
                    return false;
                }
                testUserId = new RegExp("^[0-9][a-zA-Z0-9]{0,50}$");
                if (testUserId.test(loginName)) {
                    alert("昵称不能以数字开头");
                    return false;
                }
                testUserId = new RegExp("\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*");
                if (testUserId.test(loginName)) {
                    alert("昵称不能是邮箱地址");
                    return false;
                }
                testUserId = new RegExp("^[a-zA-Z][a-zA-Z0-9]{1,50}$");
                if (!testUserId.test(loginName)) {
                    alert("昵称格式不正确");
                    return false;
                }
            }
            else if (loginType == 3) {
                if (loginName == "") {
                    alert("手机号不能为空");
                    return false;
                }
                if (!testUserId.test(loginName)) {
                    alert("手机号格式不正确");
                    return false;
                }
            }
            else if (loginType == 2) {
                if (loginName == "") {
                    alert("邮箱不能为空");
                    return false;
                }
                testUserId = new RegExp("\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*");
                if (!testUserId.test(loginName)) {
                    alert("邮箱格式不正确");
                    return false;
                }
            }
            else {
                if (loginName == "") {
                    alert("益盟号不能为空");
                    return false;
                }
            }
            return true;
        }

        $(document).ready(function () {
            $(".dp_m .cnt .topbar .navi .nitem7").addClass("naover7");
            $("#itemsboxwrap").css("margin-left", "-300px");
        });
    </script>
</body>
</html>
